#region File Description
//-----------------------------------------------------------------------------
// AnimatedSprite.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace SadlandVillage
{
  public class MessageSprite
  {
    #region Fields
    private SpriteSheet sheet;
    private Vector2 positionValue;
    private Vector2 originValue;
    private Vector2 scaleValue;
    private float rotationValue;
    private bool visible;
    private string text;
    private SpriteFont fontTexture;
    private GameBuilding building;
    #endregion

    #region Public Properties
    public Vector2 Position
    {
      set
      {
        positionValue = value;
      }
      get
      {
        return positionValue;
      }
    }

    public Vector2 Origin
    {
      set
      {
        originValue = value;
      }
      get
      {
        return originValue;
      }
    }

    public float Rotation
    {
      set
      {
        rotationValue = value;
      }
      get
      {
        return rotationValue;
      }
    }

    public Vector2 ScaleValue
    {
      set
      {
        scaleValue = value;
      }
      get
      {
        return scaleValue;
      }
    }

    public bool Visible
    {
      set
      {
        visible = value;
      }
      get
      {
        return visible;
      }
    }
    public string Text
    {
      set
      {
        text = value;
      }
      get
      {
        return text;
      }
    }
    public SpriteFont FontTexture
    {
      set
      {
        fontTexture = value;
      }
      get
      {
        return fontTexture;
      }
    }

    public GameBuilding Building
    {
      set
      {
        building = value;
      }
      get
      {
        return building;
      }
    }


    #endregion

    #region Contructors
    public MessageSprite(SpriteSheet spriteSheet, int Width,
        int Height)
    {
      if (spriteSheet == null)
      {
        throw new ArgumentNullException("spriteSheet");
      }

      sheet = spriteSheet;

      sheet.AddSourceSprite(0, new Rectangle(0, 0, Width, Height));

    }
    #endregion

    #region Methods

    public void Draw(SpriteBatch batch, Color color, SpriteBlendMode blendMode)
    {
      if (Visible)
      {
        batch.Begin(blendMode, SpriteSortMode.Immediate,
            SaveStateMode.None);
        
        batch.Draw(sheet.Texture, Vector2.Zero, sheet[0],
            color, rotationValue, originValue, scaleValue,
            SpriteEffects.None, 0f);
        
        //batch.DrawString(fontTexture, Text, new Vector2(positionValue.X + 5, positionValue.Y + 2), Color.White);
        batch.DrawString(fontTexture, Text, new Vector2( 5, 2), Color.White,rotationValue,originValue,scaleValue,SpriteEffects.None,0f);
        batch.End();
      }
    }
    #endregion
  }
}
